<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>主题色切换</title>
  <style>
    .wrapper {

      width: 100%;
      height: 100vh;
    }
  </style>
</head>

<body>
  <div class="wrapper">
  </div>
  <script>
    let i = 1
    const mainBody = document.querySelector('.wrapper')
    mainBody.onclick = function () {
      // 切换深色主题
      if (i % 2 == 0) {
        mainBody.style.backgroundColor = 'red'
      }
      else {
        mainBody.style.backgroundColor = '#060511'

      }
      i++
    };
  </script>
</body>

</html>